

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
import com.baomidou.mybatisplus.generator.config.PackageConfig;
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert;
import com.baomidou.mybatisplus.generator.config.querys.MySqlQuery;
import com.baomidou.mybatisplus.generator.config.rules.DateType;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;


public class CodeGenerator {

   

    public static void main(String[] args) {
        
        AutoGenerator generator = new AutoGenerator();
        GlobalConfig gc = new GlobalConfig();
        String projectPath = System.getProperty("user.dir");
        gc.setOutputDir(projectPath+"/src/main/java"); 
        gc.setFileOverride(true); 
        gc.setOpen(false);
        gc.setEnableCache(false); 
        gc.setAuthor("xianming");
        gc.setSwagger2(true);
        gc.setBaseResultMap(false); 
        gc.setDateType(DateType.TIME_PACK); 
        gc.setBaseColumnList(true);
        gc.setEntityName("%s");
        gc.setControllerName("%sController");
        gc.setServiceName("I%sService");
        gc.setServiceImplName("%sServiceImpl");
        gc.setMapperName("I%sMapper");
        gc.setXmlName("%sMapper");
        gc.setIdType(IdType.AUTO); 
        generator.setGlobalConfig(gc);

        DataSourceConfig dc = new DataSourceConfig();
        dc.setDbQuery(new MySqlQuery());
        dc.setDbType(DbType.MYSQL);
        dc.setTypeConvert(new MySqlTypeConvert()); 
        dc.setUrl("jdbc:mysql://localhost:3306/sieryou-wxapp?serverTimezone=CTT&useUnicode=true&characterEncoding=utf-8&useSSL=false");
        dc.setDriverName("com.mysql.cj.jdbc.Driver");
        dc.setUsername("root");
        dc.setPassword("Qanzonesql001");
        generator.setDataSource(dc);

        PackageConfig pc = new PackageConfig();
        pc.setParent("com.sieryou.admin");
        generator.setPackageInfo(pc);
        InjectionConfig cfg = new InjectionConfig() {
            @Override
            public void initMap() {
            }
        };

        generator.setCfg(cfg);

 
        StrategyConfig sc = new StrategyConfig();
        sc.setCapitalMode(false); 
        sc.setSkipView(false); 
        sc.setNaming(NamingStrategy.underline_to_camel);
        sc.setColumnNaming(NamingStrategy.underline_to_camel); 
        sc.setEntityLombokModel(true); 
        sc.setRestControllerStyle(true); 
        sc.setEntitySerialVersionUID(true); 
        sc.setEntityColumnConstant(true); 
        sc.setEntityTableFieldAnnotationEnable(true); 
        sc.setControllerMappingHyphenStyle(false); 
//        sc.setLogicDeleteFieldName("status");
        sc.setInclude("adv_module");
        generator.setStrategy(sc);

        generator.setTemplateEngine(new VelocityTemplateEngine());
        generator.execute();
    }
}
